<template>
	<view>
		<view style="padding-bottom: 50upx;padding-top: 20upx;">
			<view class="list">
				<text style="color: #999;font-size: 13px;">公司名称</text>
				<view>
					<input type="text" placeholder="填写公司名称" v-model="company_name">
				</view>
			</view>
			<view class="list">
				<text style="color: #999;font-size: 13px;">所属部门</text>
				<view>
					<input type="text" placeholder="所属部门 " v-model="section">
				</view>
			</view>
			<view class="list">
				<text style="color: #999;font-size: 13px;">所属职位</text>
				<view>
					<input type="text" placeholder="所属职位" v-model="job_name">
				</view>
			</view>
			<view class="list">
				<text style="color: #999;font-size: 13px;">在职时间</text>
				<view class="" style="display: flex;">
					<KXDateTime :date='date' :end='enddate' :start='startdate' @rundata='kxdatetime' default='start'
						placeholder="请选择开始时间" :haha="false"></KXDateTime>
					<text style="padding-right: 40px;">至</text>
					<KXDateTime :date='dated' :end='enddated' :start='startdated' @rundata='kxdatetimed' default='start'
						placeholder="请选择结束时间" :haha="false"></KXDateTime>
				</view>
			</view>
			<view class="list">
				<text style="color: #999;font-size: 13px;">工作内容</text>
				<view>
					<textarea name="" id="" cols="30" rows="10" placeholder="请输入" v-model="job_content" style="width: 100%;height: 600upx;"></textarea>
				</view>
			</view>	
		</view>
		<view @click="cun" :class="company_name!==''?'baocun':'nocun'">
			保存
		</view>
	</view>
</template>

<script>
	import KXDateTime from "@/components/kx-datetime/kx-datetime.vue"
	export default {
		data() {
			return {
				text: '',
				single: "2021-04-3",
				iszhan: false,
				isZhi: false,
				imageValue: [],
				turl: '',
				iscity: false,
				sex: 0,
				shopId: '',
				titles: '',
				salary: '',
				dianzan: '',
				max: 50,
				nums: 1,
				imglist: [],
				chooseImg: [],
				goodsid: '',
				src: '',
				imageStyles: {
					width: 60,
					height: 60,
				},
				dataList: [],
				types: 'video',
				turl: '',
				tvideo: '',
				zhiweiId: null,
				goodsinfo: {},
				describe: '',
				zhiwei: '请选择',
				xinzi: '请选择',
				imgurl: '',
				spurl: '',
				useid: '',
				startDate: "1900-01-01",
				endDate: "2030-01-01",
				pickerDate: '2022-01-25',
				array: ['选择学历'],
				arrays: ['选择性别', '男', '女'],
				xuelist: [],
				indexw: 0,
				indexd: 0,
				listData: [],
				pickerValueDefault: [0, 0],
				pickerText: '请选择',
				zhilist: [],
				birth: '',
				userinfo: {},
				position_id: '',
				isShow: false,
				upLoadAction: '',
				edu_id: '',
				city_id: '',
				evaluation: '',
				pdfurl: '',
				formData: {},
				topId: '',
				zhenImg: '',
				headerImg: '',
				company_name: '',
				section: "",
				job_name: '',
				start_time: '',
				end_time: '',
				job_content: '',
				datetimerange: ["2010-03-20", "2023-05-10 10:10:10"],
				date: '',
				enddate: '2023-05-10',
				startdate: '2000-01-01',
				dated: '',
				enddated: '2022-12-31',
				startdated: '2000-01-01',
				school_professional: '',
				school_name: '',
				sjdate:''
			}
		},
		onLoad(option) {
			this.useid = option.useid
			this.sex = option.sex
			this.pickerDate = option.birth
			this.edu_id = option.edu_id
			this.position_id = option.position_id
			this.evaluation = option.evaluation
			this.pdfurl = option.resume_url
			this.salary = option.salary
			this.pickerText = option.pickerText
			this.indexw = option.indexw
			this.zhiwei = option.zhiwei
			this.indexd = option.indexd
			this.user_name = option.user_name
			this.typed = option.type
			this.topId = option.useId
			this.zhenImg = option.zhen_Img
			this.headerImg = option.headImg
			this.school_professional = option.school_professional
			this.school_name = option.school_name
			this.city_id = option.city_id
			this.sjdate = option.sjdate
		},
		components: {
			KXDateTime
		},
		watch: {
			datetimesingle(newval) {
				console.log("单选:", this.datetimesingle);
			},
			range(newval) {
				console.log("范围选:", this.range);
			},
			datetimerange(newval) {
				console.log("范围选:", this.datetimerange);
			},
		},
		methods: {
			kxdatetime(e) {
				this.date = e
			},
			kxdatetimed(e) {
				this.dated = e
			},
			change(e) {
				this.single = e;
				console.log("-change事件:", e);
			},
			cun() {
				console.log(this.dated,this.date)
				var chu = this.date.substring(0,4)
				var lizhi = this.dated.substring(0,4)
				console.log( chu,lizhi)
				if(lizhi>chu){
					if(this.company_name!=='' || this.section!=='' || this.job_content!==''){
						this.$http.newk({
							company_name: this.company_name,
							section: this.section,
							start_time: this.date,
							job_name: this.job_name,
							end_time: this.dated,
							job_content: this.job_content
						}).then(res => {
							if(res.status == 200){
								
								uni.showToast({
									title:'保存成功'
								})
								setTimeout(()=>{
									uni.navigateTo({
										url:`./index?useid=${this.useid}`
									})
								},1500)
							}
							console.log(res)
							
						})
					}else{
						uni.showToast({
							title:'请填写完整信息',
							icon:'none'
						})
					}
				}else{
					uni.showToast({
						title:'离职时间要在入职时间之后',
						icon:"none"
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nocun{
		width: 690upx;
		height: 82upx;
		background: #999;
		border-radius: 10upx;
		margin: 0 auto;
		text-align: center;
		line-height: 82upx;
		color: #FFFFFF;
	}
	.baocun {
		width: 690upx;
		height: 82upx;
		background: #FF3D3D;
		border-radius: 10upx;
		margin: 0 auto;
		text-align: center;
		line-height: 82upx;
		color: #FFFFFF;
	}

	.xuexiao {
		width: 100%;
		height: 868upx;
		background-color: #fff;
		position: fixed;
		bottom: 0;
		z-index: 6666;
	}

	.header {
		position: fixed;
		background-color: #fff;
		height: 110upx;
		width: 100%;
		top: 40upx;
		left: 0;
		display: flex;
		z-index: 100;
		align-items: center;
		padding-left: 30upx;
	}

	.mask {
		width: 100%;
		height: 100%;
		position: absolute;
		background: rgba(0, 0, 0, 0.2);
		top: 0;
		left: 0;
		z-index: 100;
		cursor: pointer;
		transition: all 0.15s;
	}

	.content {
		width: 100%;
		overflow: hidden;
	}

	.path {
		font-size: 14px;
		word-break: break-all;
	}

	.onelist {
		width: 100%;
		// height: 500upx;
		z-index: 102;
		background-color: #FFFFFF;
		position: fixed;
		// z-index: 66;
		top: 0upx;
		display: flex;
		left: 0;
		padding-bottom: 40upx;
		flex-direction: column;

		.twolist {
			display: flex;
			padding: 30upx;
			justify-content: space-between;
			border-bottom: 2upx solid #EEEEEE;
			width: 100%;
		}
	}

	.tou {
		display: flex;
		width: 100%;
		height: 180upx;
		justify-content: space-between;
		padding: 30upx;
		align-items: center;
		border-bottom: 2upx solid #EEEEEE;
	}

	.list {
		display: flex;
		flex-direction: column;
		padding: 20upx;
		justify-content: center;
		border-bottom: 2upx solid #EEEEEE;

		view {
			padding-top: 15upx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 100%;
			color: #000;
		}
	}
</style>
